package com.yimi.yinhepda.adapter.RecycleAdapter

import android.content.Context
import android.widget.Button
import com.yimi.yinhepda.R
import com.pda.ym.base.CommonRecycleAdapter
import com.pda.ym.base.CommonViewHolder
import com.uce.pda.module.ConnectionResultLister
import com.yimi.yinhepda.db.dao.FuncBtnTableDao
import com.yimi.yinhepda.db.table.FuncBtnTable

/**
 * @author: lj
 * Date: 2020/3/31 14:28
 * Description:添加应用列表适配器
 */
class AddFuncAdapter(var context: Context?, dataList: MutableList<FuncBtnTable>,var resultLister: ConnectionResultLister<FuncBtnTable>)
    : CommonRecycleAdapter<FuncBtnTable>(context, dataList, R.layout.item_add_func) {

    override fun bindData(holder: CommonViewHolder?, data: FuncBtnTable?, position: Int) {
        holder?.setText(R.id.tv_func_name, data?.name)
        holder?.setImageResource(R.id.iv_func_pic, data!!.picId)
        val btnAdd = holder?.getView<Button>(R.id.btn_add)
        if (data?.isAdd == 1) {
            btnAdd?.text = "已添加"
            btnAdd?.isEnabled = false
        } else {
            btnAdd?.text = "添加"
            btnAdd?.isEnabled = true
        }

        btnAdd?.setOnClickListener {
            if (resultLister!=null){
                resultLister.getResult(0,data);
            }
        }
    }

}